package com.heima.behavior.controller;

import com.heima.behavior.service.BehaviorService;
import com.heima.model.common.dtos.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/api/v1")
public class BehaviorController {

    @Autowired
    private BehaviorService behaviorService;

    /**
     * 用户点赞
     *
     * @param behaviorDto
     * @return
     */
    @PostMapping("/likes_behavior")
    public ResponseResult likesBehavior(@RequestBody LikesBehaviorDto behaviorDto, @RequestHeader("userId") String userId){
        log.info("用户点赞：{},用户id：{}",behaviorDto,userId);
        return behaviorService.likesBehavior(behaviorDto,userId);
    }

    /**
     * 用户阅读
     *
     * @param behaviorDto
     * @return
     */
    @PostMapping("/read_behavior")
    public ResponseResult readBehavior(@RequestBody ReadBehaviorDto behaviorDto, @RequestHeader("userId") String userId){
        log.info("用户阅读：{},用户id：{}",behaviorDto,userId);
        return behaviorService.readBehavior(behaviorDto,userId);
    }

    /**
     * 用户不喜欢
     *
     * @param behaviorDto
     * @param userId
     * @return
     */
    @PostMapping("/un_likes_behavior")
    public ResponseResult unlikesBehavior(@RequestBody UnlikesBehaviorDto behaviorDto, @RequestHeader("userId") String userId){
        log.info("用户不喜欢：{},用户id：{}",behaviorDto,userId);
        return behaviorService.unlikesBehavior(behaviorDto,userId);
    }

}
